<?php
require_once ROOT_LIBRARY_UTILITY.DS. 'BaseModel.php';

class Model_Account extends BaseModel{

    public function  __construct() {
        parent::__construct();
        $this->_key = 'id';
        $this->_tableName = 'accounts';
    }

    public function checkAccountActive($accountId)
    {
        try
        {
            $sql = "SELECT COUNT(id)
                    FROM accounts
                    WHERE id = $accountId
                    AND active = ".ACTIVE;

            $result = $this->_db->fetchOne($sql);
            return $result;
        }
        catch(Zend_Db_Exception $ex)
        {
            throw new Exception($ex);
        }
    }

    public function getDataForPagination()
    {
        try
        {
            return $this->_db->select()
                    ->from('accounts')
                    ->where('account_types_id = '.USER)
                    ->order('id DESC');
        }
        catch(Zend_Db_Exception $ex)
        {
            throw new Exception($ex);
        }
    }
}
?>
